package com.dy.service.impl;

import com.dy.entity.Menu;
import com.dy.mapper.MenuMapper;
import com.dy.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dy.utils.MenuTreeBuilder;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author dy
 * @since 2022-03-02
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {


    @Override
    public List<Menu> findMenuTree() {
        //返回我们的菜单树
        //1.获取所有的菜单
        List<Menu> rootMenu = this.baseMapper.selectList(null);
        List<Menu> menuList = MenuTreeBuilder.build(rootMenu);
        return menuList;
    }


}
